//pack11jsclass

var PostData = new postData();
StartUpManager.addFunction("PostData","init");

function postData() {
    
    this.form=document.createElement("form");
    this.initialized=false;
    this.data=new hArray();

    this.init = function() {
        if(this.initialized) return;
        try {
           this.form=document.getElementById("PostData");
        } catch(e) { return false; }
        elements=this.form.getElementsByTagName("input");
        for(var fi=0; fi<elements.length; fi++) {
            //alert(elements[fi].name);
            this.data.add(elements[fi], elements[fi].name);
        }
        this.initialized=true;
    }

    this.release = function(action,elements) {
        //alert("release");
       // return;
        if(!this.initialized) this.init();
        if(elements) {
        for(var pdr=0; pdr<elements.length; pdr++) {
            item=this.data.get(elements[pdr].name);
            if(item) {
                item.value=elements[pdr].value;
                elements[pdr]=false;
            }
        }
        for(pdr=0; pdr<elements.length; pdr++) {
            if(elements[pdr]) {
                this.data.add(elements[pdr], elements[pdr].name);
            }
        }

        this.form.innerHTML="";

        ccu=this.data.get("currency");
        ocu=this.data.get("old_currency");
        if(ccu.value!=ocu.value) {
            price_from=this.data.get("price_from");
            
            if(Number(price_from.value)) {
                pf_variants=new hArray();
                pf_variants.createFromString(document.getElementById("from_variants").value);
                price_from.value=pf_variants.get(ccu.value);
            }

            price_to=this.data.get("price_to");
            if(Number(price_to.value)) {
                pf_variants=new hArray();
                pf_variants.createFromString(document.getElementById("to_variants").value);
                price_to.value=pf_variants.get(ccu.value);
            }
        }

        for(pdr=0; pdr<this.data.length; pdr++) {
            this.form.innerHTML+='\n<input type="hidden" name="'+this.data[pdr].name+'" value="'+this.data[pdr].value.value+'"/>';
        }
        }
        
        this.form.action="?state="+action;
        //alert(this.form.action);
        this.form.submit();

    }
	
}